using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace GoogleNet
{
    /// <summary>
    /// A short description of the feature. 
    /// In Google Earth, this description is displayed in the 
    /// Places panel under the name of the feature. 
    /// If a Snippet is not supplied, the first two lines of the description are used. 
    /// In Google Earth, if a Placemark contains both a description and a Snippet, the Snippet appears beneath 
    /// the Placemark in the Places panel, and the description appears in the Placemark's description balloon. 
    /// This tag does not support HTML markup. 
    /// Snippet has a maxLines attribute, an integer that specifies the maximum number of lines to display. 
    /// Default for maxLines is 2. 
    /// </summary>
    public class KmlSnippet : KmlObject, IKmlSubElement
    {
        private string tagName = "Snippet";

        #region MaxLines
        private int maxLines = 2;

        /// <summary>
        /// Gets or sets the maximum number of lines to display.
        /// </summary>
        /// <value>The max lines.</value>
        public int MaxLines
        {
            get { return maxLines; }
            set { maxLines = value; }
        } 
        #endregion

        #region IKmlSubElement Members

        #region Content
        private string content = string.Empty;

        /// <summary>
        /// A short description of the feature.
        /// </summary>
        /// <value>The content.</value>
        public string Content
        {
            get { return content; }
            set { content = value; }
        } 
        #endregion       

        /// <summary>
        /// Name of the KML tag for this specific element.
        /// </summary>
        /// <value></value>
        /// <returns></returns>
        public string TagName
        {
            get { return tagName; }
        }

        /// <summary>
        /// Generates the KML for this sub-element including its attribues and content.
        /// </summary>
        /// <param name="writer">The XML writer that will be used to generate the KML.</param>
        public void GenerateKml(XmlTextWriter writer)
        {
            writer.WriteStartElement(this.tagName);
            writer.WriteAttributeString("maxLines", maxLines.ToString());
            writer.WriteString(content);
            writer.WriteEndElement();
        }

        #endregion
    }
}
